{% load paginate_tags %}{% paginate %}
<div class="page-navi">
    <ul>
        {% if page_obj.has_previous %}
            <li><a href="{% url url_name page_obj.previous_page_number %}">&lt;</a></li>
        {% endif %}

        {% if first_page == current_page %}
            <li>
                <div class="current"><span>1</span></div>
            </li>
        {% else %}
            <li><a href="{% url url_name 1 %}">1</a></li>
        {% endif %}

        {% if pages_first > 3 %}
            <li>...</li>
        {% endif %}

        {% for page in pages %}
            {% if page == current_page %}
                <li>
                    <div class="current"><span>{{ page }}</span></div>
                </li>
            {% else %}
                <li><a href="{% url url_name page %}">{{ page }}</a></li>
            {% endif %}
        {% endfor %}

        {% if pages_last < last_page %}
            <li>...</li>
        {% endif %}

        {% if last_page != 1 %}
            {% if last_page == current_page %}
                <li>
                    <div class="current"><span>{{ last_page }}</span></div>
                </li>
            {% else %}
                <li><a href="{% url url_name last_page %}">{{ last_page }}</a></li>
            {% endif %}
        {% endif %}

        {% if page_obj.has_next %}
            <li><a href="{% url url_name page_obj.next_page_number %}">&gt;</a></li>
        {% endif %}
    </ul>
</div>
